package com.xframe.domain.task;


import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.xframe.domain.BaseModel;
import com.xframe.xdal.core.annotation.*;
import com.xframe.xdal.core.constant.AutoFillType;
import lombok.Data;

import java.io.InputStream;
import java.util.List;

/**
 * 上传任务表(试图 )
 *
 * @author xufeng
 * @version 1.0
 * @date 2023-06-15
 */
@Data
@XTable(value = "v_sys_import_task", label = "导入任务试图",tableType = TableType.SigeTableView)
@XSelectItem(keyName = "taskId",codeName = "taskNo",textName = "taskNo")
@XHasMany(typeName = "com.xframe.domain.task.ImportTaskLog",foreignKey = "taskId", targetKey = "taskId",as = "taskLogs")
public class ImportTaskView extends BaseModel {
    /**
     * ID
     */
    @JsonSerialize(using = com.fasterxml.jackson.databind.ser.std.ToStringSerializer.class)
    @AutoFill(AutoFillType.Snowflake)
    @XColumn(name = "task_id", primaryKeyFlag = true,desc = "任务ID")
    private Long taskId;

    /**
     * 任务编码 唯一  自动填充单号  IMFYYYYMMDD + 三位流水
     */
    @AutoFill(value = AutoFillType.BILLGENERATOR,args = "IMF,3",overwrite = true)
    @XColumn(uniqueFlag = true,desc = "任务编码",length = 20)
    private String taskNo;

    /**
     * 系统编码
     */
    @XColumn(desc = "系统编码",length = 20,readonly = true)
    private String sysCode;

    /**
     * 模型编码
     */
    @XColumn(desc = "模型编码",length = 50,readonly = true)
    private String modelCode;

    /**
     * 配置文件版本号
     */
    @AutoFill(defVal = "v1")
    @XColumn(desc = "配置文件版本",length = 20,readonly = true)
    private String ver;

    /**
     * 当前的语言环境
     */
    @AutoFill(defVal = "cn")
    @XColumn(desc = "语言环境",length = 20,readonly = true)
    private String language;

    /**
     * 当前的语言环境
     */
    @AutoFill(defVal = "default")
    @XColumn(desc = "queryKey",length = 20,readonly = true)
    private String queryKey;


    /**
     * 文件名称
     */
    @XColumn(desc = "文件名称",length = 500,readonly = true)
    private String fileName;

    /**
     * 状态 0 = 等待  1 = 运行中 2 = 结束
     */
    @XColumn(desc = "状态")
    private Integer status = 0;

    /**
     * 总运行时长(毫秒)
     */
    @XColumn(desc = "总运行时长(毫秒)")
    private Long totalTime = 0L;

    /**
     * 运行结果 0 = 等待中  1 = 全部成功  2 = 全部失败 3 = 部分成功
     */
    @XColumn(desc = "运行结果")
    private Integer runResult = 0;

    /**
     * 成功条数
     */
    @XColumn(desc = "成功条数")
    private Integer successCount = 0;

    /**
     * 失败条数
     */
    @XColumn(desc = "失败条数")
    private Integer failCount = 0;


    private List<ImportTaskLog> taskLogs;
}
